package com.tao.listen;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName topicTopicConsumer
 * @Author HETAO
 * @Date 2020/5/5 10:08
 */
@Component
public class topicTopicConsumer {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,
            exchange = @Exchange(value = "topics", type = ExchangeTypes.TOPIC),
            key = {"user.#"}
    ))
    public void test(String msg) {
        System.out.println("user.#" + msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,
            exchange = @Exchange(value = "topics", type = ExchangeTypes.TOPIC),
            key = {"user.*.select"}
    ))
    public void test2(String msg) {
        System.out.println("user.*.select" + msg);
    }
}
